package view;

import util.Controller;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class SunFactory implements Runnable{
    private JLayeredPane layeredPane;
    private JFrame frame;
    private boolean gameOver = false;
    private static int sumSun = 5000 ;
    private JLabel sunCount;
    private Controller controller;
    
    SunFactory(JLayeredPane layeredPane, JFrame frame, JLabel sunCount, Controller controller){
        this.controller = controller;
        this.controller.setSunFactory(this);
    	this.sunCount = sunCount;
        this.layeredPane = layeredPane;
        this.frame = frame;
        sunCount.setFont(new Font("粗体",1,15));
    }

    public void setSumSun(int sum) {
        sumSun = sum;
    }

    public int getSumsun() {
		return sumSun;
	}


    @Override
    public void run() {
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        while (!gameOver){
            try {
                Thread.sleep((int) (Math.random()*1000)+6000);
                new Thread(
                        new Sun(controller)).start();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}